Xbasic

HTTP_FETCH_PAGE2 Function

Syntax

Result as C = http_fetch_page2(method as C, url as C [,body as B [,include_headers as L [,timeout as N]]])

Arguments

methodCharacter

The method to use. Can be one of the following:

GET
POST
PUT
DELETE
urlCharacter

The URL to endpoint where the GET, POST, PUT, or DELETE request should be made.

bodyBinary

The request body. The body contains the JSON, XML, or other content expected by the API endpoint. Refer to the API documentation for the endpoint you are calling.

include_headersLogical

Default = .f.. Whether or not to include headers in the returned response.

timeoutNumeric

Default = 45000 (45 seconds). Timeout in milliseconds. If timeout is set to -1 or 0, HTTP_FETCH_PAGE2() will use the default timeout of 45000.

Returns

ResultCharacter

The response returned from the URL.

Description

Use HTTP GET or POST to retrieve the specified URL.

Discussion

The HTTP_FETCH_PAGE2() function uses Microsoft.XMLHTTP which creates an IXMLHTTPRequest object to retrieve a URL.

HTTP_FETCH_PAGE2() is not server-safe and cannot be used in an A5W environment. Use HTTP_FETCH() instead.
dim method as c = "GET"
dim url as c = "https://cat-fact.herokuapp.com/facts/"

dim result as c

result = http_fetch_page2(method,url)

showvarjson(result)

Limitations

Desktop Applications Only

See Also